//
//  Accountant.swift
//  Accountant
//
//  Created by 左忠飞 on 2021/8/9.
//

import Foundation

class Accountant {
    typealias NetWorthChanged = (Double) -> Void
    
    var netWorthChangedHandler: NetWorthChanged? = nil
    
    var netWorth:Double = 0.0 {
        didSet {
            netWorthChangedHandler?(netWorth)
        }
    }
    
    func gained(_ asset:Asset,completion:() -> Void) {
        netWorth += asset.value
        completion()
    }
}
